<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        /* 
            需求：完成随机点名
            var names = ['张三','李四','王五','赵六','孙七']
            
        */
       
        //如何获取随机数
        //随机数区间   [0,1)
        console.log(Math.random())
        console.log(Math.random())
        console.log(Math.random())
        console.log(Math.random())
        
        var names = ['张三','李四','王五','赵六','孙七'];
        

         function getRandomName(names){
             return names[getRandomInt(names.length)]
         }

         function getRandomInt(max) {
                 return Math.floor(Math.random() * max);
            }
            // var count=1;
            // while(count<=10){
            // console.log(getRandomName(names))
            // count++
            // }


            /* 得到两个数之间的随机数 */

            function getRandomArbitrary(min, max) {
                   
                 return Math.random() * (max - min) + min;
            }
            // console.log(getRandomArbitrary(10,20));
            
            var count2=1;
            while(count2<=20){
                
                console.log(Math.floor(getRandomArbitrary(10,21)))
                count2++;
            }

    </script>
</head>
<body>
    
</body>
</html>